﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ArmoryData.Character
{

    /// <summary>
    /// The spell types of the <see cref="CharacterInfo"/>
    /// </summary>
   public class SpellTypes
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="SpellTypes"/> class.
        /// </summary>
       public SpellTypes()
       {
           Rating = new Dictionary<string, string>();
           Arcane = new Dictionary<string, string>();
           Fire = new Dictionary<string, string>();
           Frost = new Dictionary<string, string>();
           Holy = new Dictionary<string, string>();
           Nature = new Dictionary<string, string>();
           Shadow = new Dictionary<string, string>();
           PetBonus = new Dictionary<string, string>();
       }

       /// <summary>
       /// Gets or sets the <see cref="CharacterInfo"/>'s spell rating.
       /// </summary>
       public Dictionary<string, string> Rating { get; set; }
       /// <summary>
       /// Gets or sets the <see cref="CharacterInfo"/>'s arcane power.
       /// </summary>
       public Dictionary<string, string> Arcane { get; set; }
       /// <summary>
       /// Gets or sets the <see cref="CharacterInfo"/>'s fire power.
       /// </summary>
       public Dictionary<string, string> Fire { get; set; }
       /// <summary>
       /// Gets or sets the <see cref="CharacterInfo"/>'s frost power.
       /// </summary>
       public Dictionary<string, string> Frost { get; set; }
       /// <summary>
       /// Gets or sets the <see cref="CharacterInfo"/>'s holy power.
       /// </summary>
       public Dictionary<string, string> Holy { get; set; }
       /// <summary>
       /// Gets or sets the <see cref="CharacterInfo"/>'s nature power.
       /// </summary>
       public Dictionary<string, string> Nature { get; set; }
       /// <summary>
       /// Gets or sets the <see cref="CharacterInfo"/>'s shadow power.
       /// </summary>
       public Dictionary<string, string> Shadow { get; set; }
       /// <summary>
       /// Gets or sets the <see cref="CharacterInfo"/>'s pet's bonus power.
       /// </summary>
       public Dictionary<string, string> PetBonus { get; set; }

       /// <summary>
       /// Gets the <see cref="CharacterInfo"/>'s minimum spell value.
       /// </summary>
        public float Min
        {
            get
            {
                string key = "value";
                if (Rating.Count > 0) key = "percent";

                float lowest = float.Parse(Arcane[key]);
                if (float.Parse(Fire[key]) < lowest) lowest = float.Parse(Fire[key]);
                if (float.Parse(Frost[key]) < lowest) lowest = float.Parse(Frost[key]);
                if (float.Parse(Holy[key]) < lowest) lowest = float.Parse(Holy[key]);
                if (float.Parse(Nature[key]) < lowest) lowest = float.Parse(Nature[key]);
                if (float.Parse(Shadow[key]) < lowest) lowest = float.Parse(Shadow[key]);
                return lowest;
            }
        }
    }
}
